<template>
  <div class="firstsbRight">
    <s-title text="网上服务能力" :btnshow="false" />
    <div id="firstsbRightChart"></div>
  </div>
</template>

<script>
import sTitle from "../../common/sTitle.vue";
import axios from "axios";
export default {
  name: "firstsbRight",
  components: {
    sTitle
  },
  data() {
    return {
      comps: [],
      ls:[
  {
    "px": 3,
    "lx": "YYSX",
    "mc": "支持预约事项数",
    "sl": 21803,
    "zb": 92.58,
    "zbzf": "92.58%",
    "tjsj": "2021-09-25T21:30:47.000+00:00"
  },
  {
    "px": 2,
    "lx": "WSZFSX",
    "mc": "支持网上支付事项数",
    "sl": 30,
    "zb": 0.13,
    "zbzf": "0.13%",
    "tjsj": "2021-09-25T21:30:47.000+00:00"
  },
  {
    "px": 1,
    "lx": "SFSX",
    "mc": "收费事项数",
    "sl": 449,
    "zb": 1.91,
    "zbzf": "1.91%",
    "tjsj": "2021-09-25T21:30:47.000+00:00"
  },
  {
    "px": 4,
    "lx": "WLSX",
    "mc": "支持物流事项数",
    "sl": 17369,
    "zb": 73.75,
    "zbzf": "73.75%",
    "tjsj": "2021-09-25T21:30:47.000+00:00"
  }
]
    };
  },
  mounted() {
    axios.get(this.$serverIp + "getNetServer").then((res) => {
      debugger
      // var echartData = { xData: [], yData: [] };
      // echartData.yData[0] = [];
      // echartData.yData[1] = [];
      // for (let i = 0; i < res.data.length; i++) {
      //   echartData.xData.push(res.data[i].ny);
      //   echartData.yData[0].push(res.data[i].yps);
      //   echartData.yData[1].push(res.data[i].rps);
      // }
      // res = this.ls;
      var echartData = { xLabel: [], sl: []};
      for(var i=0;i<res.data.length;i++){
echartData.xLabel.push(res.data[i].mc);
echartData.sl.push(res.data[i].sl);
      }
      this.setEchartHandle(echartData);
    });
   // this.setEchartHandle();
  },
  methods: {
    setEchartHandle(echartData) {
      let xLabel = echartData.xLabel;
      let _echarts = this.$echarts.init(
        document.getElementById("firstsbRightChart"),
        null,
        { devicePixelRatio: 2 }
      );
      let option = {
    tooltip:{},
    backgroundColor: '',
    animation: false,
    grid: {
        top: "5%",
        bottom: "20%",//也可设置left和right设置距离来控制图表的大小
        left:"15%",
        right:"10%"
    },
    xAxis: {
        data: xLabel,
        axisLine: {
            show: true, //隐藏X轴轴线
            lineStyle: {
                color: '#11417a'
            }
        },
        axisTick: {
            show: false //隐藏X轴刻度
        },
        axisLabel: {
            show: true,
            margin: 14,
            fontSize: 14,
            textStyle: {
                color: "#A3C0DF" //X轴文字颜色
            }
        },
         
    },
    yAxis: [
        {
            type: "value",
            gridIndex: 0,
            min: 0,
            max: 30000,
            interval: 5000,
            // splitNumber: 4,
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#113763',
                    width: 1
                },
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: true,
                lineStyle: {
                    color: '#11417a'
                }
            },
            axisLabel: {
                show: true,
                margin: 14,
                fontSize: 14,
                textStyle: {
                    color: "#A3C0DF" //X轴文字颜色
                }
            },
        },
    ],
    series: [
        {
            name: "主营业务",
            type: "bar",
            barWidth: 20,
            itemStyle: {
                normal: {
                    color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: "#07ecd9"
                        },
                        {
                            offset: 1,
                            color: "#034881"
                        }
                    ])
                }
            },
            data: echartData.sl,
            z: 10,
            zlevel: 0,
            "label": {
                "show": true,
                "position": "top",
                "distance": 10,
                fontSize:16,
                "color": "#01fff4"
            }
        },
        {
            // 分隔
            type: "pictorialBar",
            itemStyle: {
                normal:{
                    color:"#0F375F"
                }
            },
            symbolRepeat: "fixed",
            symbolMargin: 6,
            symbol: "rect",
            symbolClip: true,
            symbolSize: [20, 2],
            symbolPosition: "start",
            symbolOffset: [0, -1],
            // symbolBoundingData: this.total,
            data: echartData.sl,
            width: 25,
            z: 0,
            zlevel: 1,
        },
    ]
};
      _echarts.setOption(option);
    }
  }
};
</script>
<style scoped>
#firstsbRightChart {
  width: 100%;
  height: 23vh;
  margin-top: 10px;
}
</style>
 